package com.meisiabc.app.config;

import com.meisiabc.support.cache.MockSmsCodeCache;
import com.meisiabc.support.cache.SmsCodeCache;
import com.meisiabc.support.sms.MockSmsClient;
import com.meisiabc.support.sms.SmsClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.web.client.RestTemplate;

@Configuration
public class SmsConfig {
    @Bean
    public RestTemplate restTemplate() {
        RestTemplate restTemplate = new RestTemplate();
        return restTemplate;
    }

    @Bean
//    @Profile("prod")
    public SmsClient smsClient() {
        return new SmsClient(restTemplate());
    }

//    @Bean
//    @Profile("!prod")
//    public SmsClient smsClientMock() {
//        return new MockSmsClient(restTemplate());
//    }


    @Bean
//    @Profile("prod")
    public SmsCodeCache smsCodeCache() {
        SmsCodeCache cache = new SmsCodeCache();
        cache.start();
        return cache;
    }

//    @Bean
//    @Profile("!prod")
//    public SmsCodeCache smsCodeCacheMock() {
//        SmsCodeCache cache = new MockSmsCodeCache();
//        cache.start();
//        return cache;
//    }
}
